@echo off
echo 修复高德定位插件的Android namespace问题...

set PUB_CACHE_DIR=%LOCALAPPDATA%\Pub\Cache\hosted

:: 修复 pub.dev 版本
if exist "%PUB_CACHE_DIR%\pub.dev\amap_flutter_location-3.0.0\android\build.gradle" (
    echo 修复 pub.dev 版本...
    powershell -Command "(Get-Content '%PUB_CACHE_DIR%\pub.dev\amap_flutter_location-3.0.0\android\build.gradle') -replace 'android \{', 'android {`r`n    namespace ''com.amap.flutter.amap_flutter_location''' | Set-Content '%PUB_CACHE_DIR%\pub.dev\amap_flutter_location-3.0.0\android\build.gradle'"
)

:: 修复 pub.flutter-io.cn 版本
if exist "%PUB_CACHE_DIR%\pub.flutter-io.cn\amap_flutter_location-3.0.0\android\build.gradle" (
    echo 修复 pub.flutter-io.cn 版本...
    powershell -Command "(Get-Content '%PUB_CACHE_DIR%\pub.flutter-io.cn\amap_flutter_location-3.0.0\android\build.gradle') -replace 'android \{', 'android {`r`n    namespace ''com.amap.flutter.amap_flutter_location''' | Set-Content '%PUB_CACHE_DIR%\pub.flutter-io.cn\amap_flutter_location-3.0.0\android\build.gradle'"
)

echo 修复完成！
pause
